<template>
  <div class="login">
    <div class="close" @click="$router.push('/userInfo')">
      <img src="../../assets/Search/3.png" alt="" />
    </div>
    <h1>欢迎登录</h1>
    <div class="form">
      <div class="item">
        <span class="iconfont">
          <img src="../../assets/Search/33.png" alt="" />
        </span>
        <input type="text" placeholder="手机号码" v-model="phone" />
      </div>
      <div class="item">
        <span class="iconfont">
          <img src="../../assets/Search/32.png" alt="" />
        </span>
        <input type="password" placeholder="密码" v-model="pass" />
      </div>
      <div class="item">
        <div class="submit" @click="getCode">提交</div>
      </div>
    </div>
  </div>
</template>

<script>
import { Notify } from "vant";
import { getcypher } from "../../api/base";

export default {
  data() {
    return {
      phone: "",
      pass: "",
      pduan:true
    };
  },
  methods: {
    getCode() {
      // 1.验证手机号
      let reg =
        /^(13[0-9]|14[5|7]|15[0|1|2|3|4|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/;
      if (!reg.test(this.phone)) {
        Notify({ type: "warning", message: "请输入正确手机号码" });
        return;
      }
      getcypher({ phone: this.phone, password: this.pass }).then((data) => {
      
        if (data.code == 502) {
          Notify({ type: "danger", message: "登录失败" });
          return;
        } else {
          Notify({ type: "success", message: "登录成功" });
          let qaz = JSON.stringify(data)
          localStorage.setItem('pduan',qaz);
          this.$router.push('/recommend')
        }
      });
    },
    
  },
};
</script>

<style lang="less" >
.login {
  background-color: #d4473c;
  width: 100%;
  height: 667px;
  color: #fff;
  position: relative;
}
.close {
  position: absolute;
  top: 20px;
  right: 20px;
  img {
    width: 30px;
  }
}
h1 {
  font-size: 48px;
  text-align: center;
  height: 48px;
  padding: 150px 0 40px 0;
}
.form {
  .item {
    width: 76%;
    height: 30px;
    line-height: 30px;
    margin: 0 auto;
    background-color: #f47378;
    border-radius: 30px;
    margin-bottom: 12px;
    input {
      background-color: transparent;
      border: 0px;
      outline: none;
      text-indent: 0.5em;
      font-size: 14px;
      color: #fff;
    }
    span {
      font-size: 20px;
      margin-left: 10px;
      display: inline-block;
      vertical-align: middle;
      img {
        width: 20px;
      }
    }
    .getCode {
      border: 1px solid #fff;
      height: 20px;
      line-height: 20px;
      width: 50px;
      border-radius: 20px;
      font-size: 12px;
      color: #808080;
      float: right;
      margin: 5px;
    }
    .submit {
      font-size: 15px;
      background-color: #fff;
      text-align: center;
      color: #d4473c;
      border-radius: 15px;
    }
  }
}
</style>